set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go





--CREATEd:02/08/2010
--Author: nnamthach@gmail.com
alter procedure [dbo].[procProducts_getidinarraybycates](
@XmlCate as ntext,
@XmlID as ntext,
@XmlPath as nvarchar(100)
)
AS
BEGIN 

DECLARE @hDoc int
DECLARE @hDoc1 int
exec sp_xml_preparedocument @hDoc OUTPUT, @XmlCate
exec sp_xml_preparedocument @hDoc1 OUTPUT, @XmlID

SELECT     IDProduct as ID
FROM          CategoryProduct
WHERE      (IDCode   IN	(
							  SELECT ID FROM OPENXML (@hDoc, @XmlPath, 1)
							  WITH (ID int))
							)
AND (IDProduct IN (  SELECT ID FROM OPENXML (@hDoc1, @XmlPath, 1)
														  WITH (ID int)
					)
)

GROUP BY IDProduct
                          
END





